package com.example.sunmiv1.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;

import com.example.sunmiv1.R;

import butterknife.BindView;
import butterknife.OnClick;

public class DeleteGoodDialog extends BaseDialog {

    @BindView(R.id.orderSheet_remark_cancel)
    TextView orderSheetRemarkCancel;
    @BindView(R.id.orderSheet_remark_sure)
    TextView orderSheetRemarkSure;

    private String mSubmit="確定";
    public void setSubmit(String v){
        mSubmit=v;
    }

    public static DeleteGoodDialog newInstance() {
        DeleteGoodDialog fragment = new DeleteGoodDialog();
        fragment.mSubmit="確定";
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_delete_good;
    }

    @OnClick({ R.id.orderSheet_remark_cancel, R.id.orderSheet_remark_sure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.orderSheet_remark_cancel:
                dismiss();
                break;
            case R.id.orderSheet_remark_sure:
                callback.success("");
                dismiss();
                break;
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        Dialog dialog = getDialog();
        if (dialog != null) {
            // 下面這些設置必須在此方法(onStart())中才有效
            Window window = dialog.getWindow();
            // 如果不設置這句代碼, 那麼彈框就會與四邊都有一定的距離
            window.setBackgroundDrawableResource(android.R.color.transparent);
            window.setWindowAnimations(R.style.DialogFromBottom);// 設置動畫
            WindowManager.LayoutParams params = window.getAttributes();
            params.width = dp2px(350);
            window.setAttributes(setLayout(params));
        }
    }

    @Override
    protected void initView() {
        super.initView();
        orderSheetRemarkSure.setText(mSubmit);
    }
}
